﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ZH.Infrastructure.Dto.Request.Tech;
using ZH.Infrastructure.Dto.Response.Tech;
using ZH.Service.Interface;

namespace ZH.Api.Admin.Controllers.Admin
{
    /// <summary>
    /// 管理端·技法/服务
    /// </summary>
    //[Authorize(Roles = "admin")]
    public class TechniqueController : BaseController
    {
        public readonly I_Tech_Service _tech_Service;

        public TechniqueController(I_Login_Service login_Service,I_Tech_Service tech_Service) : base(login_Service)
        {
            _tech_Service= tech_Service;

        }
        /// <summary>
        /// 获取技法列表
        /// </summary>
        /// <param name="page">页面</param>
        /// <param name="limit">每页条数</param>
        /// <param name="key"></param>
        /// <returns></returns>
        [HttpGet]

        public async Task<IActionResult> Get_Tech(int? page=1,int? limit=10,string? key="") {

            var result = await _tech_Service.Get_Tech(new Tech_Response_Dto()
            {
                page = page ?? 1,
                limit = limit ?? 10,
                key = key ?? ""
            });
            return Ok(result);
        }

        /// <summary>
        /// 禁用启动技法
        /// </summary>
        /// <returns></returns>
        [HttpPost("DS_Tech/{id}")]

        public async Task<IActionResult> DS_Tech(string? id) {

            var result = await _tech_Service.DS_Tech(id);

            return Ok(result);

        }


        /// <summary>
        /// 修改技法
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Update_Tech(Tech_Request_Dto  dto) {

            var result = await _tech_Service.Update_Tech(dto);
            return Ok(result);
        }

        /// <summary>
        /// 添加技法
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Add_Tech(Tech_Request_Dto dto)
        {

            var result = await _tech_Service.Add_Tech(dto);
            return Ok(result);

        }

        /// <summary>
        /// 删除技法
        /// </summary>
        /// <returns></returns>
        [HttpPost("Delete_Tech/{id}")]
        public async Task<IActionResult> Delete_Tech(string? id)
        {

            var result = await _tech_Service.Delete_Tech(id);
            return Ok(result);

        }



    }
}
